package com.jeestudio.gateway.controller;

import com.jeestudio.common.beans.ResponseResult;
import com.jeestudio.common.enums.MsgBox;
import springfox.documentation.annotations.ApiIgnore;

/**
 * Created by shuttle on 18/8/9.
 */
@ApiIgnore
public class BaseController<T> {

    public ResponseResult success(){
        return new ResponseResult(MsgBox.SUCCESS.getCode(), MsgBox.SUCCESS.getMsg());
    }

    public ResponseResult failed(){
        return new ResponseResult(MsgBox.FAILED.getCode(), MsgBox.FAILED.getMsg());
    }

    public ResponseResult failed(MsgBox box){
        return new ResponseResult(box.getCode(), box.getMsg());
    }

    public ResponseResult failed(String msg){
        return new ResponseResult(MsgBox.FAILED.getCode(), msg);

    }

    public ResponseResult failed(int code, String msg){
        return new ResponseResult(code, msg);

    }

    public ResponseResult<T> withDataSuccess(T t){
        return new ResponseResult(MsgBox.SUCCESS.getCode(), MsgBox.SUCCESS.getMsg(), t);
    }

    public ResponseResult<T> withDataSuccess(String msg){
        return new ResponseResult(MsgBox.SUCCESS.getCode(), msg);
    }

    public ResponseResult<T> withDataSuccess(String msg, T t){
        return new ResponseResult(MsgBox.SUCCESS.getCode(), msg, t);
    }
}
